package com.bianguo.android.apushdemo.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bianguo.android.apushdemo.R;
import com.bianguo.android.apushdemo.entity.SuspensionData;

import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/9/13.
 */

public class SuspensionAdapter extends BaseRecyclerAdapter<SuspensionData> {

    public SuspensionAdapter(Context mContext, List<SuspensionData> list) {
        super(mContext, list);
    }

    @Override
    public BaseViewHolder createHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_suspension_layout, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void bindHolder(BaseViewHolder holder, int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
        SuspensionData suspensionData = list.get(position);
        int group = suspensionData.getGroup();
        viewHolder.groupTv.setText("group " + group);
        viewHolder.contentTv.setText(suspensionData.getContent());
        if (suspensionData.isShowGroup()) {
            viewHolder.groupTv.setVisibility(View.VISIBLE);
        } else {
            viewHolder.groupTv.setVisibility(View.GONE);
        }
    }

    public static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.item_suspension_group)
        TextView groupTv;
        @BindView(R.id.item_suspension_content)
        TextView contentTv;

        public ViewHolder(View itemView) {
            super(itemView);
        }
    }
}
